// import { axiosInstance, get, post, api } from "@/utils/axiosSingleton";
// const api = axiosInstance
import { api, post } from "@/utils/axiosSingleton";
import Request, { normalRequest } from "@/utils/request";
import axios from "axios";

export const login = async (username: string, password: string) => {
  const res = await normalRequest({
    url: "/api/user/login",
    method: "POST",
    data: {
      username,
      password,
    },
  });
  return res;
};

export const register = async (data: {
  username: string;
  password: string;
}) => {
  const res = await api({
    url: "/api/user/register",
    method: "POST",
    data,
  });
  return res;
};

export const singleUpload = async (formData: FormData) => {
  // const res = axios.post("/api/upload/single", formData, {
  //   headers: {
  //     "Content-Type": "multipart/form-data",
  //   },
  // });
  const res = await Request({
    // url: "/api/upload/single",
    url: "/api/upload/oss/single",
    method: "POST",
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });

  console.log("singleUpload", res);

  return res;
};
